package com.kuanter.kuanterauto.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.kuanter.kuanterauto.utils.StringUtils;
/**
 * 车险数据
 * @author soup
 *
 */
public class VehicleInfoList {
	// {"status":true,
	// "vehicleInfoList":
	// [{"id":95559,"insuranceCity":"武汉","insuranceCompany":"大地保险",
	// "insuranceStartTime":"2013-02-26","licensePlateNumber":"渝A11555","vehicleBrand":"阿尔法·罗米欧","vehicleModels":"156"}]}

	public static String TAG = "VehicleInfoList";

	private List<VehicleInfo> vehicleInfos = null;

	public VehicleInfoList(String json) {
//		System.out.println(json);
		try {
			JSONObject jobj = new JSONObject(json);
			if (StringUtils.isSuccess(json)) {
				JSONArray jarr = jobj.optJSONArray("vehicleInfoList");
				if (jarr != null && jarr.length() > 0) {
					vehicleInfos = new ArrayList<VehicleInfo>();

					for (int i = 0; i < jarr.length(); i++) {
						VehicleInfo info = new VehicleInfo();
						JSONObject jo = jarr.optJSONObject(i);
						info.setId(jo.optString("id"));
						info.setInsuranceCity(jo.optString("insuranceCity"));
						info.setInsuranceCompany(jo
								.optString("insuranceCompany"));
						info.setInsuranceStartTime(jo
								.optString("insuranceStartTime"));
						info.setLicensePlateNumber(jo
								.optString("licensePlateNumber"));
						info.setVehicleBrand(jo.optString("vehicleBrand"));
						info.setVehicleModels(jo.optString("vehicleModels"));
						info.setInspectionExpireTime(jo.optString("inspectionExpireTime"));
						info.setInsuranceCompanyId(jo.optString("insuranceCompanyId"));
						info.setInsuranceEndTime(jo.optString("insuranceEndTime"));
						vehicleInfos.add(info);
					}
				}
			}

		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public List<VehicleInfo> getVehicleInfoList() {
		return vehicleInfos;
	}
}
